import 'package:flutter/material.dart';

void main() async {
  runApp(SampleApp());
}

class SampleApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Sample App',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  final List<Map<String, String>> listOfColumns = [
    {"id":"1fe7849e-95e2-4fba-808c-4b9cede72cea","fileName":"LL6TC9VJULV5W0WB8Z.txt","startTime":"2019-3-23 08:00:00","endTime":"2019-3-23 08:10:10","status":"END"},
    {"id":"ecd461b8-33fb-43e4-a2ce-d2f38da68ea6","fileName":"S12FHYFNB7WRFA2UI2.txt","startTime":"2019-3-23 08:00:00","endTime":"2019-3-23 08:10:10","status":"END"},
    {"id":"6e3043cf-20f3-4a4b-a608-cfdfad164c1f","fileName":"4GQ9PW6J3X6QZIWAPB.txt","startTime":"2019-3-23 08:00:00","endTime":"2019-3-23 08:10:10","status":"END"}
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('文件列表'),
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: new ListView(
          children: <Widget>[
            new DataTable(
              columns: [
                DataColumn(label: Text('File')),
                DataColumn(label: Text('Start')),
                DataColumn(label: Text('End')),
                DataColumn(label: Text('Status')),
              ],
              rows: listOfColumns // Loops through dataColumnText, each iteration assigning the value to element
                      .map(
                        ((element) => DataRow(
                          cells: <DataCell>[
                            DataCell(Text(element["fileName"])),
                            DataCell(Text(element["startTime"])),
                            DataCell(Text(element["endTime"])),
                            DataCell(Text(element["status"])),
                          ],
                        )),
                      )
                      .toList(),
            )
          ],
        ),
      ),
    );
  }
}
